import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.*;
import twitter4j.Twitter;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Alexis
 */
public class Ventana extends JFrame {
      Twitter twt;
    private JLayeredPane layered;
    private JLabel fondo;
    private twiteloMenu menu;
    private int nPanel;
    public LeFrame buscar;
    private JPanel mainpanel;
    public GridBagConstraints gbc;
    twitPanel panel;
    public Ventana(Twitter twt) {
        this.setTitle("TwuiteloVentana");
        setSize(900,650);
        setResizable(false);
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        nPanel=1;
        buscar = new LeFrame(twt,this);
        panel=new twitPanel(twt,buscar);
        panel.setSize(900, 70);
        mainpanel= new JPanel(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.weighty = 0;
        //gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.gridheight = 2;
        mainpanel.setSize(900, 650);
        mainpanel.add(panel,gbc);
        gbc.weighty = 1.0;
        mainpanel.add(buscar,gbc);
        menu=new twiteloMenu(twt); 
        setJMenuBar(menu);
        mainpanel.setOpaque(false);
        
        
        
        
        
        layered = new JLayeredPane();
        panel.setSize(900, 70);
        fondo=new JLabel();
        ImageIcon imagen = new ImageIcon(getClass().getResource("/img/fondo.jpg"));
        fondo.setIcon(imagen);
        fondo.setSize(imagen.getIconWidth(), imagen.getIconHeight());
        fondo.setSize(imagen.getIconWidth(), imagen.getIconHeight());
        addPanel(fondo);
        addPanel(mainpanel);
        add(layered);
    }
    public void relayer(){
        layered.remove(mainpanel);
        remove(layered);
        addPanel(mainpanel);
        layered.repaint();
        add(layered);
        validate();
        repaint();
    }
    private void addPanel(Component comp){
        layered.add(comp,new Integer(nPanel));
        nPanel=nPanel+1;
    }


}